// SCSS variables are information about icon's compiled state, stored under its original file name
//
// .icon-home {
//   width: $icon-home-width;
// }
//
// The large array-like variables contain all information about a single icon
// $icon-home: x y offset_x offset_y width height total_width total_height image_path;
//
// At the bottom of this section, we provide information about the spritesheet itself
// $spritesheet: width height image $spritesheet-sprites;
$down-name: 'down';
$down-x: 0px;
$down-y: 0px;
$down-offset-x: 0px;
$down-offset-y: 0px;
$down-width: 1024px;
$down-height: 1024px;
$down-total-width: 2048px;
$down-total-height: 2048px;
$down-image: '~sprite.png';
$down: (0px, 0px, 0px, 0px, 1024px, 1024px, 2048px, 2048px, '~sprite.png', 'down', );
$left-name: 'left';
$left-x: 1024px;
$left-y: 0px;
$left-offset-x: -1024px;
$left-offset-y: 0px;
$left-width: 1024px;
$left-height: 1024px;
$left-total-width: 2048px;
$left-total-height: 2048px;
$left-image: '~sprite.png';
$left: (1024px, 0px, -1024px, 0px, 1024px, 1024px, 2048px, 2048px, '~sprite.png', 'left', );
$save-name: 'save';
$save-x: 0px;
$save-y: 1024px;
$save-offset-x: 0px;
$save-offset-y: -1024px;
$save-width: 1024px;
$save-height: 1024px;
$save-total-width: 2048px;
$save-total-height: 2048px;
$save-image: '~sprite.png';
$save: (0px, 1024px, 0px, -1024px, 1024px, 1024px, 2048px, 2048px, '~sprite.png', 'save', );
$up-name: 'up';
$up-x: 1024px;
$up-y: 1024px;
$up-offset-x: -1024px;
$up-offset-y: -1024px;
$up-width: 1024px;
$up-height: 1024px;
$up-total-width: 2048px;
$up-total-height: 2048px;
$up-image: '~sprite.png';
$up: (1024px, 1024px, -1024px, -1024px, 1024px, 1024px, 2048px, 2048px, '~sprite.png', 'up', );
$spritesheet-width: 2048px;
$spritesheet-height: 2048px;
$spritesheet-image: '~sprite.png';
$spritesheet-sprites: ($down, $left, $save, $up, );
$spritesheet: (2048px, 2048px, '~sprite.png', $spritesheet-sprites, );

// The provided mixins are intended to be used with the array-like variables
//
// .icon-home {
//   @include sprite-width($icon-home);
// }
//
// .icon-email {
//   @include sprite($icon-email);
// }
//
// Example usage in HTML:
//
// `display: block` sprite:
// <div class="icon-home"></div>
//
// To change `display` (e.g. `display: inline-block;`), we suggest using a common CSS class:
//
// // CSS
// .icon {
//   display: inline-block;
// }
//
// // HTML
// <i class="icon icon-home"></i>
@mixin sprite-width($sprite) {
  width: nth($sprite, 5);
}

@mixin sprite-height($sprite) {
  height: nth($sprite, 6);
}

@mixin sprite-position($sprite) {
  $sprite-offset-x: nth($sprite, 3);
  $sprite-offset-y: nth($sprite, 4);
  background-position: $sprite-offset-x  $sprite-offset-y;
}

@mixin sprite-image($sprite) {
  $sprite-image: nth($sprite, 9);
  background-image: url(#{$sprite-image});
}

@mixin sprite($sprite) {
  @include sprite-image($sprite);
  @include sprite-position($sprite);
  @include sprite-width($sprite);
  @include sprite-height($sprite);
}

// The `sprites` mixin generates identical output to the CSS template
//   but can be overridden inside of SCSS
//
// @include sprites($spritesheet-sprites);
@mixin sprites($sprites) {
  @each $sprite in $sprites {
    $sprite-name: nth($sprite, 10);
    .#{$sprite-name} {
      @include sprite($sprite);
    }
  }
}
